<?php


namespace app\home\severs;
use BarcodeBakery\Barcode\BCGcode39;
use BarcodeBakery\Common\BCGFontFile;
use BarcodeBakery\Common\BCGColor;
use BarcodeBakery\Common\BCGDrawing;
use BarcodeBakery\Barcode\BCGcode128;


class BarcodeSever
{
//$imgurl  图片存储路径  $text  显示信息
    public static function Brcode($text){

        $color_black = new BCGColor(0, 0, 0);
        $color_white = new BCGColor(255, 255, 255);
//        $font = new BCGFontFile(EXTEND_PATH . '/font/Arial.ttf', 18);
        $font = 0;
        $drawException = null;
        try {
            $code = new BCGcode39();
            $code->setScale(2);
            $code->setThickness(30);
            $code->setForegroundColor($color_black);
            $code->setBackgroundColor($color_white);
            $code->setFont($font);
            $code->parse($text);
        } catch(\Exception $exception) {
            $drawException = $exception;
        }
//        $drawing = new BCGDrawing($code, $color_white);
        $drawing = new BCGDrawing($code, $color_white);
        header('Content-Type: image/png');
        $drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
        die();
    }

}